package com.ljh.ioc.component;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: Themberfue
 * @date: 2025/2/18 22:11
 * @description:
 */
@RequestMapping("/prop")
@ResponseBody
@Controller
public class PropertiesController {
    @Value("${my.key1}")
    public Integer myKey1;

    @Value("${my.key2}")
    public boolean myKey2;

    @RequestMapping("/read")
    public String readVal() {
        return "读取配置文件my.key1:"+ myKey1;
    }

    @PostConstruct
    public void init() {
        System.out.println("mykey1:"+ myKey1);
        System.out.println("mykey2:"+ myKey2);
    }
}
